package com.meilingcloud.biobank.service.impl;

import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.biobank.domain.Source;
import com.meilingcloud.biobank.mapper.SourceMapper;
import com.meilingcloud.biobank.service.ISourceUtilService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 样本源 Service业务层处理
 *
 * @author chenl
 * @date 2021-02-26
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Service
public class SourceUtilServiceImpl extends ServiceImpl<SourceMapper, Source> implements ISourceUtilService {


    /**
     * 获取提醒的样本源列表（身份证）
     *
     * @return {@link List}<{@link Source}>
     */
    public List<Source> getTXSources() {
        DynamicDataSourceContextHolder.push("master");//手动切换
        //设置提醒的样本源（身份证）
        LambdaQueryWrapper<Source> sourcelqw = Wrappers.lambdaQuery();
        sourcelqw.eq(Source::getVisitReminder, "1");
        List<Source> sources = this.list(sourcelqw);
        return sources;
    }

}
